{extend name="common/base" /}

{block name="body"} 
<div class="head_box">
    <i class="layui-icon layui-icon-left" data-btn="backNav" onclick="window.history.go(-1);"></i>
    <div class="t1">结束任务</div>
 </div>
 <main class="main_body">

    <form class=" layui-form plan_add_form_box" onsubmit="return false">
       <div class="plan_add_form">


          <div class="form_item">
             <div class="label">备注</div>
             <div class="b1">
                <input name="remark" class="layui-input" placeholder="请输入">
             </div>
          </div>
          <input type="hidden" name="record_id" value="{$record_id}">
          <input type="hidden" name="plan_id" value="{$plan_id}">
          <div class="form_item">
             <div class="label">手动选择时间</div>
             <input id="date" readonly name="end_time" placeholder="请选择" class="layui-input">
          </div>
          <div class="text_recode d-flex">
             <div class="flex-center gary_c9 flex-1">
                提示内容显示
             </div>
          </div>
          <div> 　</div>
       </div>
       <button class="layui-btn w100 record_over">提交</button>
    </form>
 </main>

{/block}
{block name="js"}
<script>
 layui.use(['form', 'laydate', 'util'], function () {
      var form = layui.form;
      var layer = layui.layer;
      var laydate = layui.laydate;
      var util = layui.util;

      // 日期
      laydate.render({
          elem: '#date',
          trigger:'click',
          type:'datetime',
          format: 'yyyy-MM-dd HH:mm',
          min:"{$start_time}"
       }); 
       laydate.render({
           elem: '#date1',
           trigger:'click',
           type:'datetime',
           format: 'yyyy-MM-dd HH:mm',

       });
   });
   $('.record_over').click(function(){
      let remark = $('input[name="remark"]').val();
      let end_time = $('input[name="end_time"]').val();
      let recordId = $('input[name="record_id"]').val();
      let planId = $('input[name="plan_id"]').val();
      if(!recordId) return layer.msg('工序不得为空');
      if(!end_time) return layer.msg('结束时间不得为空');
      ajaxRequest('/record_over_sumbit', {remark:remark,end_time:end_time,record_id:recordId}, 'POST', this, function (response) {
                layer.msg('操作成功', {icon: 1, time: 500}, function() {
                   window.location.href = '/record_add/'+planId;
                });
            });
   })

 </script>
{/block}

